home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Harry's Story Disc & Coloring Book
/
Harry's Story Disc & Coloring Book.iso
/
mac
/
TITLE.MST
< prev
next >
Wrap
Text File
|
1993-09-29
|
12KB
|
389 lines
'**************************************************************************
'*
'* Viewer Runtime Setup Script
'*
'**************************************************************************
'' Global variables
GLOBAL TitleShortName$
GLOBAL TitleLongName$
GLOBAL MVBFileName$
GLOBAL PromptForPath%
GLOBAL DefaultPath$
GLOBAL ProgManGroup$
GLOBAL ProgManItem$
'' If you are doing a simple Setup, then you should be able to set the
'' following variables and be ready to run. If you are setting up more than
'' one MVB file, or if you have a help file or custom DLLs, please see the
'' ModifyViewerIni subroutine. If you have more than one program manager
'' icon, please see the ModifyProgramManager subroutine. If you have any
'' custom fonts, please see the RegisterCustomFonts subroutine.
'' Set the following string to a short form of the title name
TitleShortName$ = "StoryDisc"
'' Set the following string to a long form of the title name
TitleLongName$ = "Harry's StoryDisc and Coloring Book"
'' Set the following variable to the name of the MVB file, without the extension
MVBFileName$ = "children"
'' Set the following variable to 1 if Setup is to prompt for a directory for any
'' title files that need to get installed onto the hard disk. Note that you must
'' list these files in the [Installed Title Files] section of TITLE.INF. If you
'' specify 0 then any such files will be copied to the Windows directory. You might
'' do this if you only want to copy an icon file or so.
PromptForPath% = 0
'' If you have specified 1 in PromptForPath%, set the following variable to the
'' default path that will be displayed in the dialog.
DefaultPath$ = ""
'' Set the following variable to the name of the program manager group you would like to create.
ProgManGroup$ = "Harry's StoryDisc"
'' Set the following variable to the name of the program manager icon for your title
ProgManItem$ = "StoryDisc"
'*************************************************************************
'** Mainline
'*************************************************************************
GLOBAL CUIDLL$
'' Include files
'$INCLUDE 'setupapi.inc'
'' Custom UI dll
CUIDLL$ = "mscuistf.dll"
'' Dialog ID's
CONST DESTPATH = 1000
CONST APPHELP = 2000
CONST TOOBIG = 3000
CONST BADPATH = 4000
CONST SUCCESS = 5000
'' Bitmap ID
CONST LOGO = 1
'' Functions and subroutines
DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
DECLARE SUB RegisterFont(fontfile$, fontname$)
DECLARE SUB ModifyViewerIni
DECLARE SUB RegisterCustomFonts
DECLARE SUB ModifyProgramManager
DECLARE SUB ShowSuccess
'' The following statement turns size checking off. Set it to scmOnFatal to enable
'' size checking, where Setup will compare the disk file size with the INF file size
'' and report an error if they are not the same.
i% = SetSizeCheckMode(scmOff)
'' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to alter the banner bitmap.
SetTitle "Harry's StoryDisc Setup"
SetBitmap CUIDLL$, LOGO
'' Read in the INF file.
ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
'' Decide where to put title files
IF PromptForPath% = 1 THEN
szTitleDir$ = GetTitleDir(DefaultPath$)
IF szTitleDir$ = "" THEN
GOTO QUIT
ENDIF
ELSE
szTitleDir$ = GetWindowsDir()
ENDIF
'' Copy files
IF CopyFiles(szTitleDir$) = 0 THEN
GOTO QUIT
ENDIF
'' Create the MVIEWER2.EXE MVB association
CreateIniKeyValue "WIN.INI", "Extensions", "MVB", "mviewer2.exe", cmoNone
'' Register in VIEWER.INI
ModifyViewerIni
'' Register custom fonts
RegisterCustomFonts
'' Modify Program Manager
ModifyProgramManager
'' Success dialog
ShowSuccess
'' Now start the title
RUN "mviewer2.exe " + MVBFileName$ + ".MVB", NOWAIT
QUIT:
END
'*************************************************************************
'** Purpose:
'** Prompts the user for a path for the title files
'** Arguments:
'** szDefault$ - default path
'** Returns:
'** New valid path name, or "" if the user quit.
'*************************************************************************
FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
SetSymbolValue "String", TitleShortName$
SetSymbolValue "EditTextIn", szDefault$
SetSymbolValue "EditFocus", "ALL"
GETPATH:
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
IF sz$ = "CONTINUE" THEN
szTitleDir$ = GetSymbolValue("EditTextOut")
IF IsDirWritable(szTitleDir$) = 0 THEN
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
GOTO GETPATH
END IF
UIPop 1
CreateDir szTitleDir$, cmoNone
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATH
ELSE
szTitleDir$ = ""
END IF
GetTitleDir = szTitleDir$
END FUNCTION
'*************************************************************************
'** Purpose:
'** Copies the files in the INF file
'** Arguments:
'** szTitleDir$ - destination directory for the title files
'** Returns
'** 1 if files were copied, 0 otherwise
'*************************************************************************
FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
'' Add all system files to the copy list
AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
'' Add all of the title files to the copy list
AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
'' Check size
szExtras$ = "Extra"
szCosts$ = "Costs"
szNeededs$ = "Neededs"
FOR i% = 1 TO 26 STEP 1
AddListItem szExtras$, "0"
NEXT i%
'' We assume that VIEWER.INI will take another 4K
ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
'' Get amount of space required
StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
'' Put up a message if there is not enough space
FOR i% = 1 TO 26 STEP 1
IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
TOOBIG:
sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO TOOBIG
END IF
UIPop 1
CopyFiles = 0
GOTO DONTCOPY
END IF
NEXT i%
'' Copy the files
CopyFilesInCopyList
CopyFiles = 1
DONTCOPY:
END FUNCTION
'*************************************************************************
'** Purpose:
'** Puts up a success dialog
'*************************************************************************
SUB ShowSuccess STATIC
SUCCESS:
SetSymbolValue "String1", TitleShortName$
sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO SUCCESS
END IF
UIPop 1
END SUB
'*************************************************************************
'** Purpose:
'** Appends a file name to the end of a directory path,
'** inserting a backslash character as needed.
'** Arguments:
'** szDir$ - full directory path (with optional ending "\")
'** szFile$ - filename to append to directory
'** Returns:
'** Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
MakePath = szFile$
ELSEIF szFile$ = "" THEN
MakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
MakePath = szDir$ + szFile$
ELSE
MakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
'*************************************************************************
'** Purpose:
'** Registers a font.
'** Arguments:
'** fontfile$ - font filename
'** fontname$ - font name.
'*************************************************************************
SUB RegisterFont(fontfile$, fontname$) STATIC
'' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
IF AddFont(fontfile$, fontname$) = 0 THEN
j% = DoMsgBox("Could not install " + fullfontfile$ + " font.", "Viewer Font Installation", 0)
ENDIF
END SUB
'*************************************************************************
'** Purpose:
'** Registers title in VIEWER.INI
'*************************************************************************
SUB ModifyViewerIni STATIC
'' Get the VIEWER.INI file
szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
'' First register the title file, setting the Name and Path entries. We assume that the
'' MVB file is the same directory as SETUP.EXE.
CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
CreateIniKeyValue szIni$, "vwrhelp", "Name", "Harry's StoryDisc Help", cmoOverwrite
CreateIniKeyValue szIni$, "vwrhelp", "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
'' If you are installing any other MVB files then you would want to add extra Name and Path
'' entries for each here.
'' Now we have to register the MVB file in the [FILES] section, so that Viewer can find
'' files that are not on the path and display a special message when a file is not found.
CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
CreateIniKeyValue szIni$, "FILES", "vwrhelp" + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
'' You would want to add similar entries here if you are including a help file or any custom DLLs.
END SUB
'*************************************************************************
'** Purpose:
'** Creates program manager entries for the title
'*************************************************************************
SUB ModifyProgramManager STATIC
'' Create the program manager group
CreateProgmanGroup ProgmanGroup$, "", cmoNone
ShowProgmanGroup ProgmanGroup$, 1, cmoNone
'' Create an entry for the title
CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), "harry.ico", cmoOverwrite
'' Add other program manager groups as required here. Note that the 4th parameter in the above line
'' can be set to an icon file to customize the icon.
END SUB
'*************************************************************************
'** Purpose:
'** Registers custom fonts with Windows.
'*************************************************************************
SUB RegisterCustomFonts STATIC
'' If you install custom fonts, then you will want to add lines here of the following
'' form in order to register them with the current Windows session and to add them to
'' the WIN.INI fonts section. Note that TrueType fonts can only be installed on a Win 3.1
'' machine - RegisterFont automatically creates the required .FOT file for TrueType fonts.
''
'' RegisterFont mistral.ttf, "Mistral (TrueType)"
''
END SUB